#!/usr/bin/env python
# -*- coding: utf-8 -*-

#from Ft.Xml import Parse
import sys
sys.path.append('./lib')
import libxml2
import libxslt
import paths
import config

print "Content-type: text/xml\n"
conf = config.config()
path = conf.internal.base+'config/'
xmlfile = path+'modules_conf.xml'
xslfile = path+'modules_conf.xsl'
#doc = Parse(path+'modules_conf.xml')
xml = libxml2.parseFile(xmlfile)
styleDoc = libxml2.parseFile(xslfile)
style = libxslt.parseStylesheetDoc(styleDoc)
result = style.applyStylesheet(xml, None)
style.freeStylesheet()
menu = file(conf.local.htdocs+'menu.xml', 'w')
menu.write(str(result))
menu.close()
print """<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="../index.xsl"?><page><message>TYPE:html
<br/></message><base>/cgi-bin/index.py/</base><content>
<b>Some text here1</b>
</content></page>
"""
#from Ft.Xml.Xslt import Processor
#from Ft.Xml import InputSource
#sty = InputSource.DefaultFactory.fromUri(path+'modules_conf.xsl')
#processor = Processor.Processor()
#processor.appendStylesheet(sty)
#s = processor.runNode(doc)